package com.xiaomi.service.impl;

import com.xiaomi.dao.UserDao;
import com.xiaomi.dao.impl.UserDaoImpl;
import com.xiaomi.entity.User;
import com.xiaomi.service.UserService;

/**
 * TODO
 *
 * @ClassName UserServiceImpl
 * @Author jy
 * @Date 2021/5/22
 */
public class UserServiceImpl implements UserService {

    private final UserDao userDao = new UserDaoImpl();

    @Override
    public User checkUser(String username) {
        try {
            return userDao.checkUser(username);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }

    @Override
    public int register(User user) {
        try {
            return userDao.register(user);
        } catch (Exception e) {
            return -1;
        }
    }

    @Override
    public User login(String username, String password) {
        try {
            return userDao.login(username, password);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
}
